package com.ruoyi.waterManagement.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.business.waterManagement.StManstatR;
import com.ruoyi.common.core.domain.business.waterManagement.StStationR;
import com.ruoyi.waterManagement.service.IStManstatRService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 水情人工观测站数据记录Controller
 * 
 * @author hwd
 * @date 2023-02-21
 */
@RestController
@RequestMapping("/StManstatR")
public class StManstatRController extends BaseController
{
    @Autowired
    private IStManstatRService stManstatRService;

    /**
     * 查询水情人工观测站数据记录列表
     */
    @RequiresPermissions("waterManagement:StManstatR:list")
    @GetMapping("/list")
    public TableDataInfo list(StManstatR stManstatR)
    {
        startPage();
        List<StManstatR> list = stManstatRService.selectStManstatRList(stManstatR);
        return getDataTable(list);
    }

    /**
     * 导出水情人工观测站数据记录列表
     */
    @RequiresPermissions("waterManagement:StManstatR:export")
    @Log(title = "水情人工观测站数据记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StManstatR stManstatR)
    {
        List<StManstatR> list = stManstatRService.selectStManstatRList(stManstatR);
        ExcelUtil<StManstatR> util = new ExcelUtil<StManstatR>(StManstatR.class);
        util.exportExcel(response, list, "水情人工观测站数据记录数据");
    }

    /**
     * 根据测站代码及上报时间获取水情人工观测站数据记录详细信息
     */
    @RequiresPermissions("waterManagement:StManstatR:query")
    @GetMapping(value = "/getInfo")
    public AjaxResult getInfo(StManstatR stManstatR)
    {
        if (stManstatR.getChkTime()==null){
            return error();
        }
        return success(stManstatRService.selectStManstatRByStatCdAndCheckTime(stManstatR));
    }

    /**
     * 新增水情人工观测站数据记录
     */
    @RequiresPermissions("waterManagement:StManstatR:add")
    @Log(title = "水情人工观测站数据记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StManstatR stManstatR)
    {
        return toAjax(stManstatRService.insertStManstatR(stManstatR));
    }

    /**
     * 修改水情人工观测站数据记录
     */
    @RequiresPermissions("waterManagement:StManstatR:edit")
    @Log(title = "水情人工观测站数据记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StManstatR stManstatR)
    {
        return toAjax(stManstatRService.updateStManstatR(stManstatR));
    }

//    /**
//     * 删除水情人工观测站数据记录
//     */
//    @RequiresPermissions("waterManagement:StManstatR:remove")
//    @Log(title = "水情人工观测站数据记录", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{statCds}")
//    public AjaxResult remove(@PathVariable String[] statCds)
//    {
//        return toAjax(stManstatRService.deleteStManstatRByStatCds(statCds));
//    }

    /**
     * 根据测站代码及上报时间删除水情人工监测站数据记录
     */
    @RequiresPermissions("waterManagement:StManstatR:remove")
    @Log(title = "水情在线监测站数据记录", businessType = BusinessType.DELETE)
    @DeleteMapping
    public AjaxResult remove(StManstatR stManstatR)
    {
        return toAjax(stManstatRService.deleteStManstatRByStatCdAndCheckTime(stManstatR));
    }

    /**
     * 查询遗漏时间点
     */
    @ApiOperation("查询测站水位流量遗漏时间点")
    @GetMapping("/selMissingTime")
    public AjaxResult selMissingTime(StManstatR stManstatR) throws Exception {
        return AjaxResult.success(stManstatRService.selMissingTime(stManstatR));
    }
}
